﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TrembleAction : SSAction
{
    float radian = 0;
    float addRadian = 1.0f;
    float radius = 0.01f;
    Vector3 initPosition;
    public float time = 1.0f;

    public override void Start()
    {
        initPosition = transform.position;
    }

    public static TrembleAction GetSSAction()
    {
        TrembleAction tremble = CreateInstance<TrembleAction>();
        return tremble;
    }

    public override void Update()
    {
        time -= Time.deltaTime;
        if (time <= 0)
        {
            transform.position = initPosition;
            this.destroy = true;
            this.callback.SSActionEvent(this);
        }
        radian += addRadian;
        float dy = Mathf.Cos(radian) * radius;
        transform.position = initPosition + new Vector3(0, dy, 0);
    }

    public override void FixedUpdate() { }
}